package com.jtpay.sdk.adapter;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.jtpay.sdk.R;
import com.zhy.autolayout.utils.AutoUtils;

import apiUtils.models.ChannelModel;
import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/8/22.
 */

public class ChannelAdapter extends BaseRecycleAdapter<ChannelModel> {

    @Override
    protected RecyclerView.ViewHolder createView(ViewGroup parent, int type) {
        View view = mLayoutInflater.inflate(R.layout.item_channel, parent, false);
        return new Holder(view);
    }

    @Override
    protected void unSelected(RecyclerView.ViewHolder viewHolder, int position) {
        Holder holder = (Holder) viewHolder;
        holder.mSignImageView.setVisibility(View.INVISIBLE);
    }

    @Override
    protected void selected(RecyclerView.ViewHolder viewHolder, int position) {
        super.selected(viewHolder, position);
        Holder holder = (Holder) viewHolder;
        holder.mSignImageView.setVisibility(View.VISIBLE);
    }

    @Override
    protected void setView(RecyclerView.ViewHolder viewHolder, int position) {
        ChannelModel model = mList.get(position);
        Holder holder = (Holder) viewHolder;
        holder.mChannelTextView.setText(model.getChannelName());
    }

    class Holder extends RecyclerView.ViewHolder {
        @Bind(R.id.channel_name)
        TextView mChannelTextView;
        @Bind(R.id.item_right_sign)
        ImageView mSignImageView;

        public Holder(View itemView) {
            super(itemView);
            AutoUtils.autoSize(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
